////////////////////////////////////////////////////////////////////////////////
//Copyright (c) 2010 Michal Szczepanski - (http://vane.pl)
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.
////////////////////////////////////////////////////////////////////////////////
package pl.vane.as3relax
{
	import flash.events.Event;
	
	/**
	 * The CouchEvent class is the event object for CouchEvent events.
	 * 
	 * @langversion ActionScript 3.0
	 * @playerversion Flash 9.0
	 * @tiptext
	 */
	public class CouchEvent extends Event
	{
		
		/**
		 * The <code>CouchEvent.DATA</code> constant defines the value of the
		 * <code>type</code> property of the event object for an <code>couchevent.data</code> event.
		 *
		 * <p>The action property of the event object have the following values:</p>
		 * <table class="innertable">
		 *    <tr><th>Property</th><th>Value</th></tr>
		 *    <tr><td><code>action</code></td><td>changes | compact | delete | get | post  | put | replicate | uuid</td></tr>
		 * </table>
		 *
		 * @eventType couchevent.data
		 * 
		 * @langversion ActionScript 3.0
		 * @playerversion Flash 9.0
		 * @tiptext
		 */
		public static const DATA:String = "couchevent.data"; 
		
		/**
		 * The <code>CouchEvent.DATA</code> constant defines the value of the
		 * <code>type</code> property of the event object for an <code>couchevent.fault</code> event.
		 *
		 * <p>The action property of the event object have the following values:</p>
		 * <table class="innertable">
		 *    <table class="innertable">
		 *    <tr><th>Property</th><th>Value</th></tr>
		 *    <tr><td><code>action</code></td><td>changes | compact | delete | get | post  | put | replicate | uuid</td></tr>
		 * </table>
		 *
		 * @eventType couchevent.fault
		 * 
		 * @langversion ActionScript 3.0
		 * @playerversion Flash 9.0
		 * @tiptext
		 */
		public static const FAULT:String = "couchevent.fault";
		
		/**
		 * Defines action of the CouchEvent when returning 
		 * <code>data</code> from the CouchDB API
		 * 
		 * @see pl.vane.as3relax.CouchEventAction
		 * 
		 * @langversion ActionScript 3.0
		 * @playerversion Flash 9.0
		 * @tiptext
		 */ 
		public var action:String;
		
		/**
		 * Data Object returned by the CouchEvent used to transmit data by the event
		 * 
		 * @langversion ActionScript 3.0
		 * @playerversion Flash 9.0
		 * @tiptext
		 */ 
		public var data:*;
		
		/**
		 * Constructor.
		 * 
		 * @langversion ActionScript 3.0
		 * @playerversion Flash 9.0
		 * @tiptext
		 */ 
		public function CouchEvent(action:String, type:String = "couchevent.data", bubbles:Boolean=false, cancelable:Boolean=false)
		{
			this.action = action;
			super(type, bubbles, cancelable);
		}
		
		/**
		 * Returns separate instance of this CouchEvent
		 * 
		 * @langversion ActionScript 3.0
		 * @playerversion Flash 9.0
		 * @tiptext
		 */
		override public function clone() : Event {
			var e:CouchEvent = new CouchEvent(this.action, this.type, this.bubbles, this.cancelable);
			e.data = this.data;
			return e;
		}
	}
}
